package com.javaziliao.design.dprecated.state;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DeprecatedOrderContext {

    //无状态
    @Autowired
    private DeprecatedCreateOrder deprecatedCreateOrder;
    @Autowired
    private DeprecatedPayOrder deprecatedPayOrder;
    @Autowired
    private DeprecatedSendOrder deprecatedSendOrder;
    @Autowired
    private DeprecatedReceiveOrder deprecatedReceiveOrder;


    // 创建订单的入口方法，直接调用状态类的createOrder方法
    public DeprecatedOrder createOrder(String orderId, String productId) {
        return deprecatedCreateOrder.createOrder(orderId, productId, this);
    }

    // 支付订单的方法入口，直接调用状态类的payOrder方法
    public DeprecatedOrder payOrder(String orderId) {
        return deprecatedPayOrder.payOrder(orderId, this);
    }

    public DeprecatedOrder sendOrder(String orderId) {
        return deprecatedSendOrder.sendOrder(orderId, this);
    }

    public DeprecatedOrder receiveOrder(String orderId) {
        return deprecatedReceiveOrder.receiveOrder(orderId, this);
    }

}
